
import { scrollMixin } from "utils/mixin";
export default {
  mixins: [scrollMixin],
  data() {
    return {
      infoData: {},
      continue_days: "", //连续签到天数
      sign_total: "", //累计签到天数
      cumulative: "", //累计奖励
      sign_log: [], //签到记录
      sign_name: "", //签到名字
      integral: "",
      sign_model:"",
      love_name:"",
      love_return: "",//累计爱心返回值
      is_love:false,//是否安装了爱心值插件
      cumulative_point:'',//累计积分
      cumulative_coupon:'',//累计优惠劵
      cumulative_love:'',//累计爱心值
      point:'',

      page: 1,
      isLoadMore: true,
    };
  },
  methods: {
    getMoreData() {
      if (this.current_page >= this.last_page) {
        return;
      }
      this.isLoadMore = false;
      this.page = this.current_page + 1;
      this.getData();
    },
    getData() {
      $http
        .get(
          "plugin.sign.Frontend.Modules.Sign.Controllers.sign-log.log",
          {
            page:this.page
          },
          "loading"
        )
        .then(res => {
          this.sign_log = this.sign_log.concat(res.data.sign_log.data);
          this.current_page = res.data.sign_log.current_page;
          this.last_page = res.data.sign_log.last_page;
          this.isLoadMore = true;
          if(this.page > 1) {
            return;
          }
          this.infoData = res.data;
          this.continue_days = res.data.continue_days;
          this.sign_total = res.data.sign_total;
          this.cumulative =
            window.localStorage.integral + res.data.cumulative.substr(2);
          this.integral = window.localStorage.integral;

          this.sign_name = res.data.sign_name;
          this.love_name = res.data.love_name||'爱心值';
          this.is_love = res.data.is_love;
          this.love_return = res.data.love_return;
          this.sign_model = res.data.sign_model;
          this.fun.setWXTitle(this.sign_name + "记录");
          this.cumulative_love = res.data.sign_model.cumulative_love;
          this.cumulative_coupon = res.data.sign_model.cumulative_coupon;
          this.cumulative_point = res.data.sign_model.cumulative_point;
          this.point = this.fun.getCustomTextLang('member_center.credit1','积分');
        });
    },

    continueDays(){
      if(this.continue_days == '暂无') {
        return  0;
      }  else { return this.continue_days.substring(0,this.continue_days.length-1);}
    },
    initData(){
      this.page = 1;
      this.isLoadMore = true;
    },
    toUrl(name) {
      this.$router.push(this.fun.getUrl(name, {}));
    }
  },
  activated() {

  },
  deactivated() {
  },
  mounted(){
  },
  created() {
    this.initData();
    this.getData();
  },
  computed:{
    signTotal(){
      return this.sign_total.substring(0,this.sign_total.length-1);
    },
  },
  components: {  }
};
